# -*- coding: utf-8 -*- 

###########################################################################
## Python code generated with wxFormBuilder (version Oct  8 2012)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################

import wx
import wx.xrc
import wx.combo
import wx.html
import gettext
from common.version import program_name,program_version
from common.dy_import.dy_import import Dynload
import os

###########################################################################
## Class dict_Frame
###########################################################################

class mainFrame ( wx.Frame ):
	
	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = program_name(), pos = wx.DefaultPosition, size = wx.Size( 650,450 ), style = wx.CAPTION|wx.DEFAULT_FRAME_STYLE|wx.FRAME_SHAPED|wx.SYSTEM_MENU|wx.TAB_TRAVERSAL )
		self.current_dict=[]
		for a in os.listdir("modules"):
			if os.path.isdir("modules/"+a) and os.path.isfile("modules/"+a+"/"+a+".py"):
				self.current_dict.append(a)		
		self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
		
		bSizer1 = wx.BoxSizer( wx.VERTICAL )
		
		bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
		
		self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _("Search:"), wx.DefaultPosition, wx.Size( -1,-1 ), wx.ALIGN_CENTRE|wx.ST_NO_AUTORESIZE )
		self.m_staticText1.Wrap( -1 )
		self.m_staticText1.SetFont( wx.Font( 14, 77, 90, 90, False, "Ubuntu" ) )
		
		bSizer2.Add( self.m_staticText1, 2, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL|wx.EXPAND|wx.SHAPED, 4 )
		
		self.m_bcomboBox1 = wx.combo.BitmapComboBox( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, "", wx.TE_PROCESS_ENTER | wx.WANTS_CHARS) 
                self.m_bcomboBox1.SetFont( wx.Font( 11, 74, 90, 90, False, "Sans" ) )		
		bSizer2.Add( self.m_bcomboBox1, 12, wx.ALL|wx.EXPAND, 1 )
		
		self.m_bpSearch = wx.BitmapButton( self, wx.ID_ANY, wx.Bitmap( u"gui/image/arrow_ex.jpg", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.Size( 50,-1 ), wx.BU_AUTODRAW )
		self.m_bpSearch.SetDefault() 
		bSizer2.Add( self.m_bpSearch, 0, wx.ALL|wx.EXPAND|wx.SHAPED, 1 )
		
		self.m_bpRead = wx.BitmapButton( self, wx.ID_ANY, wx.Bitmap( u"gui/image/read_ex.jpg", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
		bSizer2.Add( self.m_bpRead, 0, wx.ALL|wx.EXPAND|wx.SHAPED, 1 )
		
		
		bSizer1.Add( bSizer2, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALIGN_TOP|wx.EXPAND|wx.TOP, 5 )
		#*******************************************************************
		bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
		self.m_split=wx.SplitterWindow(self,wx.ID_ANY,wx.DefaultPosition,wx.DefaultSize,wx.SP_3D)
		self.m_split.SetSashGravity(0.5)
		self.m_split.SetMinimumPaneSize(120)

		#............................................................
		bSizer4 = wx.BoxSizer( wx.VERTICAL )
		self.m_pnl1=wx.Panel(self.m_split,wx.ID_ANY)
		self.m_staticText3 = wx.StaticText( self.m_pnl1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( -1,22 ), wx.ALIGN_CENTRE|wx.ST_NO_AUTORESIZE|wx.NO_BORDER )
		self.m_staticText3.Wrap( -1 )
		self.m_staticText3.SetFont( wx.Font( 12, 74, 90, 92, False, "Tahoma" ) )
		self.m_staticText3.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNHIGHLIGHT ) )
		self.m_staticText3.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INACTIVECAPTIONTEXT ) )
		
		bSizer4.Add( self.m_staticText3, 0, wx.ALL|wx.EXPAND, 3 )
		
		m_listBox1Choices = []
		self.m_listBox1 = wx.ListBox( self.m_pnl1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, 0 | wx.WANTS_CHARS | wx.LB_HSCROLL|wx.LB_NEEDED_SB|wx.LB_SINGLE|wx.LB_SORT)
		self.m_listBox1.SetFont( wx.Font( 12, 74, 90, 92, False, "Consolas" ) )
		bSizer4.Add( self.m_listBox1, 9, wx.ALL|wx.EXPAND, 4 )
		
		
		self.m_pnl1.SetSizer(bSizer4)
		#bSizer3.Add( bSizer4, 1, wx.EXPAND, 5 )
		#............................................................
		bSizer5 = wx.BoxSizer( wx.VERTICAL )
		self.m_pnl2=wx.Panel(self.m_split,wx.ID_ANY)
		self.m_html = wx.html.HtmlWindow( self.m_pnl2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.html.HW_SCROLLBAR_AUTO )
		bSizer5.Add( self.m_html, 1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 3 )
		
		
		self.m_pnl2.SetSizer(bSizer5)		
		self.m_split.SplitVertically(self.m_pnl1,self.m_pnl2,160)
		
		bSizer3.Add(self.m_split,3, wx.EXPAND, 5)
		#bSizer3.Add( bSizer5, 3, wx.EXPAND, 5 )
		
		#***************************************************************************
		bSizer1.Add( bSizer3, 10, wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.EXPAND, 5 )
		
		
		self.SetSizer( bSizer1 )
		self.Layout()
		self.m_statusBar1 = self.CreateStatusBar( 3, wx.ST_SIZEGRIP, wx.ID_ANY )
		self.m_statusBar1.SetStatusWidths([-2,-1,-1])

		self.m_menubar1 = wx.MenuBar( 0 )
		self.m_menu1 = wx.Menu()
		self.m_menuItem1 = wx.MenuItem( self.m_menu1, wx.ID_ANY, _("Option"), _("you can change the option here."), wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem1 )
		self.m_menuItem8 = wx.MenuItem( self.m_menu1, wx.ID_ANY, _("Clear History"), _("all histories will be cleared."), wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem8 )
		self.m_menu1.AppendSeparator()
		
		self.m_menuItem2 = wx.MenuItem( self.m_menu1, wx.ID_ANY, _("&Quit")+ u"\t" + u"ALT-Q", _("quit the program"), wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem2 )
		
		self.m_menubar1.Append( self.m_menu1, _("&File") ) 
		
		####appending dict menus############################
		self.m_menu2 = wx.Menu()
		self.menu_dict={}
		self.crs={}
		temp3=0
		for i in self.current_dict:
			temp3+=1
			b=[]
			a = wx.Menu()
			
			temp=Dynload("modules.%s.%s" % (i,i),['.'])
			temp2=temp.getClassInstance("d_"+i)
			c=temp.execMethod(temp2,"getdict_name")
			self.crs[i]=c
			
			b.append(i)
			b.append(wx.MenuItem( a, wx.ID_ANY, _("Use %s?")%c, _("to specify whether to use %s") % c, wx.ITEM_CHECK ))
			if temp3<=9:
				b[1].SetItemLabel(b[1].GetLabel() + "\tCtrl-%d" % temp3)
			elif temp3==10:
				b[1].SetItemLabel(b[1].GetLabel() + "\tCtrl-0")
				
			a.AppendItem( b[1] )
		
			a.AppendSeparator()
		
			b.append(wx.MenuItem( a, wx.ID_ANY, _("Option"), _("change the Dict option"), wx.ITEM_NORMAL ))
			a.AppendItem( b[2] )
			b[2].Enable(False)
			
			
		
			b.append(wx.MenuItem( a, wx.ID_ANY, _("About %s") % c, _("copyright of %s") % c , wx.ITEM_NORMAL ))
			a.AppendItem( b[3] )
		
			self.m_menu2.AppendSubMenu( a, c )
			self.menu_dict[i]=b
			
		temp=Dynload("modules.baidu.baidu",['.'])
		temp2=temp.getClassInstance("d_baidu")
		self.dict_list=temp.execMethod(temp2,"getwordlist")	
		self.menu_dict["baidu"][1].Check(True)
		self.menu_dict["baidu"][2].Enable(True)
		self.m_staticText3.SetLabel(self.crs["baidu"])
		self.cr="baidu"
		
		self.m_menubar1.Append( self.m_menu2, _("Dicts" )) 
		#####################################################
		self.m_menu3 = wx.Menu()
		self.m_menuItem9 = wx.MenuItem( self.m_menu3, wx.ID_ANY, _("Help"), _("help"), wx.ITEM_NORMAL )
		self.m_menu3.AppendItem( self.m_menuItem9 )
		
		self.m_menu3.AppendSeparator()
		
		self.m_menuItem10 = wx.MenuItem( self.m_menu3, wx.ID_ANY, _("&About")+ u"\t" + u"F1", _("About this program"), wx.ITEM_NORMAL )
		self.m_menu3.AppendItem( self.m_menuItem10 )
		
		self.m_menubar1.Append( self.m_menu3, _("Help") ) 
		
		self.SetMenuBar( self.m_menubar1 )
		
		
		self.Centre( wx.BOTH )

				
	def __del__( self ):
		pass
	

